package com.octnote.repository;

import com.octnote.domain.note.UserNote;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RestResource;

import java.util.Collection;

/**
 * 记事Note NotesRepository定义
 * 
 * @author leohehe
 *
 */
@RestResource(exported = false) // 禁止暴露REST
public interface NoteRepository extends CrudRepository<UserNote, Long> {

	Collection<UserNote> findAll();


	Page<UserNote> findByNoteTypeContaining(String searchPhrase, Pageable p);

	@Modifying
	@Query("update UserNote as u set u.multiFileUri = :multiFileUri  where u.id = :id")
	int updateUserNoteFileUri(@Param("id")Long id, @Param("multiFileUri")String multiFileUri);
}
